from tokenize import generate_tokens, untokenize, NAME,OP,STRING, NUMBER
from StringIO import StringIO
def decistmt(s):
    """Substitute Decimals for floats in a string of statements.

    >>> from decimal import Decimal
    >>> s = 'print +21.3e-5*-.1234/81.7'
    >>> decistmt(s)
    "print +Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7')"

    >>> exec(s)
    -3.21716034272e-007
    >>> exec(decistmt(s))
    -3.217160342717258261933904529E-7

    """
    result = []
    g = generate_tokens(s.readline)   # tokenize the string
    for toknum, tokval, _, _, _  in g:
        result.append((toknum, tokval))
    return result

print decistmt(open("teste.pas", "r"))